﻿using AutoMapper;
using PcProject.Domain.IRepository;
using PcProject.Domain.Models.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PcProject.Application.Service.Order
{
    public class OrderService:IOrderService
    {
        /// <summary>
        /// 构造函数依赖注入
        /// </summary>
        private IOrderRepository _orderRepository;
        private IMapper _mapper;
        /// <summary>
        /// 函数依赖注入
        /// </summary>
        /// <param name="productRepository"></param>
        /// <param name="mapper"></param>
        public OrderService(IOrderRepository orderRepository, IMapper mapper)
        {
            _orderRepository = orderRepository;
            _mapper = mapper;
        }


        /// <summary>
        /// 显示+分页+查询
        /// </summary>
        /// <param name="number">查询参数</param>
        /// <param name="pageIndex">页数</param>
        /// <param name="pageSize">条数</param>
        /// <param name="totalCount">总条数</param>
        /// <returns></returns>
        public List<OrderAll> GetOrdersAsync(string number, int pageIndex, int pageSize, out int totalCount)
        {
            return _orderRepository.GetOrdersAsync(number, pageIndex, pageSize, out totalCount);
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="obj">表单参数</param>
        /// <returns></returns>
        public async Task<int> InsertAsync(Orders obj)
        {
            return await _orderRepository.InserAsync(obj);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        public async Task<int> DeleAsync(int id)
        {
            return await _orderRepository.DeleAsync(id);
        }

        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        public async Task<OrderAll> FillAsync(int id)
        {
            return await _orderRepository.FillAsync(id);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="obj">表单参数</param>
        /// <returns></returns>
        public async Task<int> UptAsync(Orders obj)
        {
            return await _orderRepository.UptAsync(obj);
        }

    }
}
